package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CategoryMapper {
    //添加菜品类别
    @Insert("insert into category values (null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    //分页管理
    @Select("select * from category order by sort")
    List<Category> findAll();

    //删除菜品数据
    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    //修改菜品信息
    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void update(Category category);

    //根据type查询菜品类型列表
    List<Category> list(@Param("type") Integer type);

    //根据id查找菜品类别
    @Select("select * from category where id=#{id}")
    Category findById(Long categoryId);
}
